package com.dct.test;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.dct.activity.R;
import com.dct.dao.MemberDTO;
import com.dct.util.MemberUtil;

public class MainActivity extends Activity {
	EditText edt;
	Button bt, pBt;
	String phoneNumber;
	@Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        edt = (EditText)findViewById(R.id.edt);
        
        bt = (Button)findViewById(R.id.btn);
        pBt = (Button)findViewById(R.id.pBtn);
        bt.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				try {
		        	String phone = edt.getText().toString();
		        	MemberUtil util = new MemberUtil(getBaseContext());
		        	MemberDTO vo =  util.getMemberDTO(phone);
		        	edt.setText(vo.getName());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
        pBt.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
				phoneNumber = telManager.getLine1Number();
				edt.setText(phoneNumber);
			}
		});
    }
}
